package pri.zey.custom.activity;/**
 * Created by Administrator on 2016/3/12.
 */

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentActivity;

import pri.zey.custom.activity.Interfaces.IBase;

/**
 * >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>类描述
 * activity基础类
 * >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>属性描述
 * >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>方法描述
 */
public class ActivityBase extends FragmentActivity implements IBase<ActivityBase>{

    public static final int KEY_AMSGWHAT = 0x1000;
    private ActivityBase mActivity;
    private String mActivityName;
    private Message mMsg;

    protected Runnable UView;
    protected Handler mAHandler = new Handler(){
        @Override
       public void handleMessage(Message msg) {
            super.handleMessage(msg);
            switch (msg.what){
                case KEY_AMSGWHAT:
                    setMsg(msg);
                break;
                default:break;
            }
        }
    };


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if(UView != null)
            UpdateView();
    }

    private void UpdateView(){
        UpdateView(UView);
    }

    public void UpdateView(Runnable UView){
        getWindow().getDecorView().post(UView);
    }

    public void setmActivityName(String mActivityName) {
        this.mActivityName = mActivityName;
    }

    public String getmActivityAllName() {
        mActivityName = this.getClass().getName();
        return mActivityName;
    }

    @Override
    public Message getMsg() {
        return mMsg;
    }

    @Override
    public void setMsg(Message mMsg) {
        this.mMsg = mMsg;
    }

    @Override
    public ActivityBase getThis() {
        mActivity = this;
        return mActivity;
    }

    @Override
    public String getThisName() {
        mActivityName = this.getClass().getName().substring(this.getPackageName().length() + 1);
        return mActivityName;
    }


}
